#!/bin/bash

# 资产管理系统API示例请求

BASE_URL="http://localhost:8080/assets"

echo "=== 创建新资产 ==="
curl -X POST $BASE_URL \
  -H "Content-Type: application/json" \
  -d '{
    "name": "Office Laptop",
    "type": "Electronics",
    "description": "Dell XPS 15",
    "location": "Office 301",
    "value": 1200.00,
    "purchaseDate": "2023-01-15",
    "status": "In Use"
  }'
echo -e "\n"

echo "=== 创建另一个资产 ==="
curl -X POST $BASE_URL \
  -H "Content-Type: application/json" \
  -d '{
    "name": "Conference Room Projector",
    "type": "Electronics",
    "description": "Epson PowerLite",
    "location": "Conference Room A",
    "value": 800.00,
    "purchaseDate": "2022-05-20",
    "status": "In Use"
  }'
echo -e "\n"

echo "=== 获取所有资产 ==="
curl -X GET $BASE_URL
echo -e "\n"

echo "=== 获取ID为1的资产 ==="
curl -X GET "$BASE_URL/1"
echo -e "\n"

echo "=== 更新ID为1的资产 ==="
curl -X PUT "$BASE_URL/1" \
  -H "Content-Type: application/json" \
  -d '{
    "name": "Office Laptop",
    "type": "Electronics",
    "description": "Dell XPS 15 - Updated",
    "location": "Office 302",
    "value": 1200.00,
    "purchaseDate": "2023-01-15",
    "status": "In Use"
  }'
echo -e "\n"

echo "=== 删除ID为2的资产 ==="
curl -X DELETE "$BASE_URL/2"
echo -e "\n"

echo "=== 最终资产列表 ==="
curl -X GET $BASE_URL
echo -e "\n"
